package com.example.mobile2021606127cxz0617homework;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class MySQLiteOpenHelper extends SQLiteOpenHelper {
    public MySQLiteOpenHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String sql = "create table staff(name varchar(20) not null,skill varchar(20) not null,xinchou integer)";
        db.execSQL(sql);
        ContentValues values=new ContentValues();
        values.put("name","张三");
        values.put("skill","安卓开发工程师");
        values.put("xinchou",15000);
        db.insert("staff",null,values);
        values.put("name","李四");
        values.put("skill","前端开发工程师");
        values.put("xinchou",14000);
        db.insert("staff",null,values);
        values.put("name","王五");
        values.put("skill","Java开发工程师");
        values.put("xinchou",14500);
        db.insert("staff",null,values);


    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
